using UnityEngine;
using System.Collections;
using DanielSig;
using DanielSig.UnityExtensions;

public class AgentSweller : MonoBehaviour
{
	public Renderer Sweller;
	public float SwellingTime;
	[Range(0,1)]
	public float StartAlpha;
	
	private Color _normalColor;
	private Color _currentColor;
	private float _countDown;
	void Start()
	{
		_normalColor = Sweller.material.color;
	}
	
	void FlashScreen(Color color)
	{
		Sweller.material.color = _currentColor = color.SetAlpha(StartAlpha);
		_countDown = SwellingTime;
	}
	void FlashScreen(Vector3 color)
	{
		Sweller.material.color = _currentColor = new Color(color.x, color.y, color.z, StartAlpha);
		_countDown = SwellingTime;
	}
	void Update()
	{
		if(_countDown > 0)
		{
			_countDown -= Time.deltaTime;
			Sweller.material.color = Color.Lerp(_normalColor, _currentColor, _countDown / SwellingTime);
		}
	}
}

